/*
 ============================================================================
 Name        : FileHandler.h
 Author      : Sherry Krikszer
 Version     : 1.0
 Copyright   :
 Description : in C, Ansi-style
 ============================================================================
 */

#ifndef FILEHANDLER_H_
#define FILEHANDLER_H_

#include "Common.h"

/* ----------------------------------------------------------------------------
 *	Constants Definition
 * ----------------------------------------------------------------------------*/

#define MAX_FILE_LINE_COUNT MAX_LINE_COUNT

/* ----------------------------------------------------------------------------
 *	Constants Definition End
 * ----------------------------------------------------------------------------*/

/* ----------------------------------------------------------------------------
 *	Type Definition
 * ----------------------------------------------------------------------------*/

typedef struct
{
	FileLine FileLine[MAX_FILE_LINE_COUNT];
	int lineCounter;
}FileLines;

/* ----------------------------------------------------------------------------
 *	Type Definition End
 * ----------------------------------------------------------------------------*/

/* ----------------------------------------------------------------------------
 *	Function Declaration
 * ----------------------------------------------------------------------------*/

/* Reads the the file's contents and returns it's lines as a list of strings,
 * if read fails a null pointer is returned
 * Note : the list is initialized within this method but the calling method is responsible
 * 		  to free the returned list */
FileLines* ReadLinesFromFile(const char *fileName);

/* TODO : write documentation for this method */
void FreeFileLines(FileLines* fileLines);

/* Create a file with the given list as it's contents
 * TRUE is returned in case files was successfully written, false otherwise
 * Note : the given list is expected to be a string list */
Boolean WriteFile(const char *fileName, FileLines* lineList);

/* ----------------------------------------------------------------------------
 *	Function Declaration End
 * ----------------------------------------------------------------------------*/

#endif /* FILEHANDLER_H_ */
